package com.poker.utils;


import sun.misc.BASE64Encoder;
import java.io.FileInputStream;
import java.io.IOException;
import java.io.InputStream;

public class FileUtils {

    public static String imageToBase64(String fullPath) {

        InputStream in = null;
        byte[] data = null;
        try {
            in = new FileInputStream(fullPath);
            data = new byte[in.available()];
            in.read(data);
            in.close();
        } catch (IOException e) {
            e.printStackTrace();
        }

        BASE64Encoder encoder = new BASE64Encoder();
        System.out.println(encoder.encode(data));
        return ("data:image/png;base64,") + encoder.encode(data).replaceAll("\n|\r", "");


    }


}
